<#include "../common/header.htm">
<div class="content-wrapper">
	<section class="content">
		<form action="${ctx}/platrole/list" method="get" id="listForm">
			<div class="box">
				<div class="box-header">
					<div class="row">
						<div class="col-sm-11">
							<div class="col-sm-2">
								<input name="roleCode" type="text" class="form-control" value="${roleCode!}" placeholder="请输入角色编码" />
							</div>
								<!--<div class="col-sm-2">-->
								<input type="button"  class="btn btn-primary" onclick="platRoles.query();" value="分析" />
								<input type="button"  class="btn btn-primary" onclick="platRoles.form();" value="新增" />
							<!--</div>-->
						</div>
					</div>
				</div>
				<div class="box-body">
					<table class="table table-hover table-bordered table-striped">
						<thead>
							<tr>
								<th>#</th>
								<th>角色ID</th>
								<th>角色编码</th>
								<th>角色名</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
							<#list page.content as u>
							<tr>
								<td>${page.size * page.number + u_index + 1}</td>
								<td>${u.roleId!}</td>
								<td>${u.roleCode!}</td>
								<td>${u.roleName!}</td>
								<td>
									<a href="javascript:void(0)" onclick="platRoles.form('${u.roleId}')">编辑</a>&nbsp;&nbsp;
									<a href="javascript:void(0)" onclick="platRoles.authorizationForm('${u.roleId}')">角色授权</a>&nbsp;&nbsp;
									<#-- 
									<a href="${ctx}/platrole/deleteOne?roleId=${u.roleId}">删除</a>
									 -->
								</td>
							</tr>
							</#list>
						</tbody>
					</table>
					<#include "../common/page.htm">
				</div>
			</div>
		</form>
	</section>
</div>

<script type="text/javascript">
	var is_submit=false;
	var platRoles = {
		query: function () {
			$(":input[name='pageNumber']").val(0);
			$("form").submit();
		},
		form : function(id){
			if(is_submit){
				return;
			}
			is_submit=true;
			id = id ? id : "";
			var title = id?"修改角色":"新增角色";
			var j = 0;
			base.getView({
				url:"${ctx}/platrole/form?roleId="+id,
				success:function(result){
					bootbox.dialog({
						title:title,
						message:result,
						size:"large",
						closeButton : false,
						buttons:{
							cancel:{
								label:"取消",
								className:"btn btn-secondary",
								callback:function(){
									is_submit=false;
								}
							},
							sure:{
								label:"确定",
								className:"btn btn-primary",
								callback:function(){
									if (j != 0) {
										is_submit=false;
										return ;
									}
									j++;
									base.validAndAjaxSubmit($("#addPlatRole"), $("#listForm"), function () {
										j = 0;
									});
									return false;
								}
							}
						}
					})
				}
			})
		},
		authorizationForm : function(id){
			if(is_submit){
				return;
			}
			is_submit=true;
			id = id?id:"";
			var title = "<label ondblclick ='checkAll(0)'>角色授权</label>";
			var j = 0;
			base.getView({
				url:"${ctx}/platrole/authorizationForm?roleId="+id,
				success:function(result){
					bootbox.dialog({
						title:title,
						message:result,
						size:"large",
						closeButton : false,
						buttons:{
							cancel:{
								label:"取消",
								className:"btn btn-secondary",
								callback:function(){
									is_submit=false;
								}
							},
							sure:{
								label:"确定",
								className:"btn btn-primary",
								callback:function(){
									if (j != 0) {
										is_submit=false;
										return ;
									}
									j++;
									base.validAndAjaxSubmit($("#authorizationForm"), $("#listForm"), function () {
										j = 0;
									});
									return false;
								}
							}
						}
					})
				}
			})
		}
	}
</script>
<style>
	.box-body {
		padding-left: 20px;
		padding-right: 10px;
	}
	.col-sm-11 {
		margin-bottom: 10px;
	}
	.box-header {
		padding-top: 10px;
	}
	input.form-control {
		border-radius: 4px;
		font-size: 12px;
	}
	input.btn.btn-default,
	input.btn.btn-primary {
		width: 70px;
		margin-right: 10px;
	}
	.btn-primary:active:focus{
		background-color: #52A1FE;
		border-color: #52A1FE;
	}
	.btn-primary{
		background-color:#4595ec;
		border-color:#4595ec;
	}
	.btn-primary:hover, .btn-primary:active, .btn-primary.hover{
		background-color:#61a8f5;
		border-color:#61a8f5;
	}
	.btn-primary.focus, .btn-primary:focus{
		background-color:#4595ec;
		border-color:#4595ec;
	}
	input.btn.btn-primary {
		width: 70px;
		margin-right: 48px;
		margin-left: -43px;
		height: 30px;
		line-height: 17px;
	}
	.table{
		margin-bottom: 0;
	}
</style>